import 'package:fate_blind_box/theme/theme_color.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import '../../Home/activity/act_details_page.dart';
import '../../Home/activity/act_list_model.dart';

class MyActListView extends StatelessWidget {
  FuturePopular? dataModel = FuturePopular();

  MyActListView({Key? key, this.dataModel}) : super(key: key);
  double leftMargin = 14.w;
  double picWidth = 179.w;
  double picHeight = 108.w;
  double sevenSpace = 7;
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        Get.to(ActDetailsPage(
          actId: dataModel?.activityId ?? '',
          dataModel: dataModel,
        ));
      },
      child: Container(
        padding: EdgeInsets.all(leftMargin),
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            ClipRRect(
                borderRadius: BorderRadius.circular(5),
                child: dataModel!.actiCover!.isEmpty
                    ? Container()
                    : Image.network(
                        dataModel?.actiCover ?? '',
                        width: picWidth,
                        height: picHeight,
                       fit: BoxFit.cover,
                      )),
            Container(
              width: 1.sw - picWidth - leftMargin * 2 - sevenSpace,
              margin:  EdgeInsets.only(left: sevenSpace),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text(
                    dataModel?.actiTitle ?? '',
                    maxLines: 2,
                    style: TextStyle(
                        color: ThemeColor.black3D3D3DColor,
                        fontSize: 16,
                        overflow: TextOverflow.ellipsis,
                        fontWeight: FontWeight.w500),
                  ),
                  const SizedBox(
                    height: 6,
                  ),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Text(
                        dataModel?.actiTime?.replaceAll('开始', '') ?? '',
                        style: TextStyle(
                            color: ThemeColor.grayA0A0A0Color, fontSize: 12),
                      ),
                      Expanded(child: Container()),
                      Text(
                        dataModel?.actiArea ?? '',
                        maxLines: 1,
                        style: TextStyle(
                            color: ThemeColor.grayA0A0A0Color,
                            fontSize: 12,
                            overflow: TextOverflow.ellipsis),
                      ),
                    ],
                  ),
                  const SizedBox(
                    height: 18,
                  ),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Text(
                        dataModel?.actiCost ?? '',
                        style: const TextStyle(
                            color: Color(0XFFE84D46),
                            fontSize: 16,
                            fontWeight: FontWeight.w500),
                      ),
                      Container(
                        padding: const EdgeInsets.symmetric(
                            horizontal: 3, vertical: 1),
                        decoration: BoxDecoration(
                            borderRadius: BorderRadius.circular(5),
                            border: Border.all(
                                color: ThemeColor.appColor, width: 1)),
                        child: Text(
                          getSignStatus(dataModel?.sign??0),
                          style: TextStyle(
                              color: ThemeColor.appColor, fontSize: 12),
                        ),
                      ),
                    ],
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }

  String getSignStatus(int sign){
    String name='我要报名';
    switch(sign){
      case -1:
        return '已结束';
      case 0:
        return '已开始';
      case 1:
        return name;
      case 2:
        return '已报名';
    }
    return name;
  }
}
